home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / xceedzip / xceedzip.exe / Samples / Zip Manager / Vb5 / frmMain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-04-27  |  34.6 KB  |  744 lines

  1. VERSION 5.00
  2. Object = "{DB797681-40E0-11D2-9BD5-0060082AE372}#4.1#0"; "XceedZip.dll"
  3. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
  4. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.1#0"; "COMCTL32.OCX"
  5. Begin VB.Form frmMain 
  6.    Caption         =   "Zip Manager Sample Application (Xceed Zip v4.0)"
  7.    ClientHeight    =   5415
  8.    ClientLeft      =   2580
  9.    ClientTop       =   1515
  10.    ClientWidth     =   8775
  11.    Icon            =   "frmMain.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   361
  14.    ScaleMode       =   3  'Pixel
  15.    ScaleWidth      =   585
  16.    Begin VB.PictureBox picStatus 
  17.       Align           =   2  'Align Bottom
  18.       Height          =   315
  19.       Left            =   0
  20.       ScaleHeight     =   17
  21.       ScaleMode       =   3  'Pixel
  22.       ScaleWidth      =   581
  23.       TabIndex        =   0
  24.       Top             =   5100
  25.       Width           =   8775
  26.       Begin ComctlLib.ProgressBar prbGlobalProgress 
  27.          Height          =   255
  28.          Left            =   6120
  29.          TabIndex        =   3
  30.          Top             =   0
  31.          Visible         =   0   'False
  32.          Width           =   1770
  33.          _ExtentX        =   3122
  34.          _ExtentY        =   450
  35.          _Version        =   393216
  36.          BorderStyle     =   1
  37.          Appearance      =   0
  38.       End
  39.       Begin VB.CommandButton cmdAbort 
  40.          Caption         =   "&Abort"
  41.          Enabled         =   0   'False
  42.          Height          =   260
  43.          Left            =   7980
  44.          TabIndex        =   1
  45.          Top             =   0
  46.          Width           =   735
  47.       End
  48.       Begin VB.Label lblProgress 
  49.          Caption         =   "Progress:"
  50.          Height          =   255
  51.          Left            =   5400
  52.          TabIndex        =   4
  53.          Top             =   30
  54.          Visible         =   0   'False
  55.          Width           =   735
  56.       End
  57.       Begin VB.Label lblStatusBar 
  58.          Caption         =   "No zip file currently opened."
  59.          Height          =   255
  60.          Left            =   45
  61.          TabIndex        =   2
  62.          Top             =   30
  63.          Width           =   5220
  64.       End
  65.    End
  66.    Begin MSComDlg.CommonDialog dlgSelectFiles 
  67.       Left            =   8400
  68.       Top             =   8280
  69.       _ExtentX        =   847
  70.       _ExtentY        =   847
  71.       _Version        =   393216
  72.    End
  73.    Begin MSComDlg.CommonDialog dlgSelectZip 
  74.       Left            =   8880
  75.       Top             =   8280
  76.       _ExtentX        =   847
  77.       _ExtentY        =   847
  78.       _Version        =   393216
  79.    End
  80.    Begin ComctlLib.ListView lstMain 
  81.       Height          =   4575
  82.       Left            =   0
  83.       TabIndex        =   5
  84.       Top             =   0
  85.       Width           =   7935
  86.       _ExtentX        =   13996
  87.       _ExtentY        =   8070
  88.       View            =   3
  89.       Arrange         =   2
  90.       LabelEdit       =   1
  91.       MultiSelect     =   -1  'True
  92.       LabelWrap       =   -1  'True
  93.       HideSelection   =   -1  'True
  94.       FullRowSelect   =   -1  'True
  95.       TextBackground  =   -1  'True
  96.       _Version        =   393217
  97.       ForeColor       =   0
  98.       BackColor       =   -2147483643
  99.       Appearance      =   1
  100.       NumItems        =   12
  101.       BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  102.          Text            =   "Name"
  103.          Object.Width           =   2646
  104.       EndProperty
  105.       BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  106.          SubItemIndex    =   1
  107.          Text            =   "Comment"
  108.          Object.Width           =   2469
  109.       EndProperty
  110.       BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  111.          SubItemIndex    =   2
  112.          Text            =   "Size"
  113.          Object.Width           =   1323
  114.       EndProperty
  115.       BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  116.          SubItemIndex    =   3
  117.          Text            =   "Packed"
  118.          Object.Width           =   1323
  119.       EndProperty
  120.       BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  121.          SubItemIndex    =   4
  122.          Text            =   "Attributes"
  123.          Object.Width           =   1429
  124.       EndProperty
  125.       BeginProperty ColumnHeader(6) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  126.          SubItemIndex    =   5
  127.          Text            =   "CRC"
  128.          Object.Width           =   1984
  129.       EndProperty
  130.       BeginProperty ColumnHeader(7) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  131.          SubItemIndex    =   6
  132.          Text            =   "Last Modified"
  133.          Object.Width           =   3175
  134.       EndProperty
  135.       BeginProperty ColumnHeader(8) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  136.          SubItemIndex    =   7
  137.          Text            =   "Last Accessed"
  138.          Object.Width           =   3175
  139.       EndProperty
  140.       BeginProperty ColumnHeader(9) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  141.          SubItemIndex    =   8
  142.          Text            =   "Created"
  143.          Object.Width           =   3175
  144.       EndProperty
  145.       BeginProperty ColumnHeader(10) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  146.          SubItemIndex    =   9
  147.          Text            =   "Path"
  148.          Object.Width           =   2646
  149.       EndProperty
  150.       BeginProperty ColumnHeader(11) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  151.          SubItemIndex    =   10
  152.          Text            =   "Method"
  153.          Object.Width           =   1323
  154.       EndProperty
  155.       BeginProperty ColumnHeader(12) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  156.          SubItemIndex    =   11
  157.          Text            =   "Encrypted"
  158.          Object.Width           =   1852
  159.       EndProperty
  160.    End
  161.    Begin XceedZipLibCtl.XceedZip xZip 
  162.       Left            =   8160
  163.       Top             =   4440
  164.       BasePath        =   ""
  165.       CompressionLevel=   6
  166.       EncryptionPassword=   ""
  167.       RequiredFileAttributes=   0
  168.       ExcludedFileAttributes=   24
  169.       FilesToProcess  =   ""
  170.       FilesToExclude  =   ""
  171.       MinDateToProcess=   2
  172.       MaxDateToProcess=   2958465
  173.       MinSizeToProcess=   0
  174.       MaxSizeToProcess=   0
  175.       SplitSize       =   0
  176.       PreservePaths   =   -1  'True
  177.       ProcessSubfolders=   0   'False
  178.       SkipIfExisting  =   0   'False
  179.       SkipIfNotExisting=   0   'False
  180.       SkipIfOlderDate =   0   'False
  181.       SkipIfOlderVersion=   0   'False
  182.       TempFolder      =   ""
  183.       UseTempFile     =   -1  'True
  184.       UnzipToFolder   =   ""
  185.       ZipFilename     =   ""
  186.       SpanMultipleDisks=   2
  187.       ExtraHeaders    =   10
  188.       ZipOpenedFiles  =   0   'False
  189.       BackgroundProcessing=   0   'False
  190.       SfxBinrayModule =   ""
  191.       SfxDefaultPassword=   ""
  192.       SfxDefaultUnzipToFolder=   ""
  193.       SfxExistingFileBehavior=   0
  194.       SfxReadmeFile   =   ""
  195.       SfxExecuteAfter =   ""
  196.       SfxInstallMode  =   0   'False
  197.       SfxProgramGroup =   ""
  198.       SfxProgramGroupItems=   ""
  199.       SfxExtensionsToAssociate=   ""
  200.       SfxIconFilename =   ""
  201.    End
  202.    Begin VB.Menu mnuFile 
  203.       Caption         =   "&File"
  204.       Begin VB.Menu mnuFileNew 
  205.          Caption         =   "&New Zip File"
  206.       End
  207.       Begin VB.Menu mnuFileOpen 
  208.          Caption         =   "&Open Zip File"
  209.       End
  210.       Begin VB.Menu mnuFileLine1 
  211.          Caption         =   "-"
  212.       End
  213.       Begin VB.Menu mnuFileSettings 
  214.          Caption         =   "&Options..."
  215.       End
  216.       Begin VB.Menu mnuFileLine2 
  217.          Caption         =   "-"
  218.       End
  219.       Begin VB.Menu mnuFileColConfig 
  220.          Caption         =   "&Column settings..."
  221.       End
  222.       Begin VB.Menu mnuFileLine3 
  223.          Caption         =   "-"
  224.       End
  225.       Begin VB.Menu mnuFileExit 
  226.          Caption         =   "&Exit"
  227.       End
  228.    End
  229.    Begin VB.Menu mnuActions 
  230.       Caption         =   "&Actions"
  231.       Begin VB.Menu mnuActionsAdd 
  232.          Caption         =   "&Add files..."
  233.       End
  234.       Begin VB.Menu mnuActionsExtract 
  235.          Caption         =   "&Unzip files..."
  236.       End
  237.       Begin VB.Menu mnuActionsLine1 
  238.          Caption         =   "-"
  239.       End
  240.       Begin VB.Menu mnuActionsRemove 
  241.          Caption         =   "&Delete file(s)..."
  242.       End
  243.       Begin VB.Menu mnuActionsTest 
  244.          Caption         =   "&Test zip file"
  245.       End
  246.    End
  247.    Begin VB.Menu mnuHelp 
  248.       Caption         =   "&Help"
  249.       Begin VB.Menu mnuHelpAbout 
  250.          Caption         =   "&About the Zip Manager Sample Application..."
  251.       End
  252.    End
  253. Attribute VB_Name = "frmMain"
  254. Attribute VB_GlobalNameSpace = False
  255. Attribute VB_Creatable = False
  256. Attribute VB_PredeclaredId = True
  257. Attribute VB_Exposed = False
  258. Option Explicit
  259. ' ===================================================================
  260. '    DESCRIPTION:  Zip Manager Sample Application for VB6
  261. '    COPYRIGHT:    Copyright 
  262. 1995-1999 Xceed Software Inc.
  263. '                  All Rights Reserved.
  264. ' ===================================================================
  265. '------------------------------------------------------------------------------------
  266. ' Update the list view with the contents of the current zip file.
  267. '------------------------------------------------------------------------------------
  268. Private Sub UpdateZipContentsList()
  269.     Dim xErr As xcdError
  270.     lstMain.ListItems.Clear
  271.     If Len(xZip.ZipFilename) = 0 Then
  272.         Caption = "Zip Manager Sample Application (Xceed Zip 4)"
  273.     Else
  274.         DisableInterface
  275.         Load frmResults
  276.         xZip.FilesToProcess = ""
  277.         lstMain.Visible = False
  278.         xErr = xZip.ListZipContents
  279.         lstMain.Visible = True
  280.         If frmResults.HasMessages Then
  281.             frmResults.Show vbModal
  282.         End If
  283.         Unload frmResults
  284.         
  285.         If (xErr = xerSuccess) Or (xErr = xerWarnings) Or (xErr = xerFilesSkipped) Then
  286.             lblStatusBar.Caption = xZip.ZipFilename & " opened."
  287.             Caption = xZip.ZipFilename & " - Zip Manager Sample Application (Xceed Zip 4)"
  288.         Else
  289.             lblStatusBar.Caption = "Could not read " & xZip.ZipFilename
  290.             xZip.ZipFilename = ""
  291.             Caption = "Zip Manager Sample Application (Xceed Zip 4)"
  292.         End If
  293.     End If
  294.     EnableInterface
  295. End Sub
  296. '------------------------------------------------------------------------------------
  297. 'Aborts the current operation
  298. '------------------------------------------------------------------------------------
  299. Private Sub cmdAbort_Click()
  300.     xZip.Abort = True
  301. End Sub
  302. '------------------------------------------------------------------------------------
  303. ' Stores the initial position of various objects for resizing purposes and
  304. ' disables some menu items
  305. '------------------------------------------------------------------------------------
  306. Private Sub Form_Load()
  307.     ' Enable or disable based on initial setup
  308.     UpdateZipContentsList
  309. End Sub
  310. '------------------------------------------------------------------------------------
  311. ' When the form is resized, the objects on it must be repositionned in order
  312. ' to stay in their correct locations
  313. '------------------------------------------------------------------------------------
  314. Private Sub Form_Resize()
  315.     lstMain.Width = frmMain.ScaleWidth
  316.     lstMain.Height = frmMain.ScaleHeight - picStatus.Height
  317.     ' Since the picture box is not yet resized, we use the form's dimensions
  318.     cmdAbort.Left = frmMain.ScaleWidth - cmdAbort.Width - 4
  319. End Sub
  320. '------------------------------------------------------------------------------------
  321. ' The "Action" main menu is selected. We update the state of the "Remove files..."
  322. ' submenu depending if files are selected
  323. '------------------------------------------------------------------------------------
  324. Private Sub mnuActions_Click()
  325.     Dim i As Integer
  326.     For i = 1 To lstMain.ListItems.Count
  327.         If lstMain.ListItems(i).Selected Then
  328.             mnuActionsRemove.Enabled = True
  329.             Exit Sub
  330.         End If
  331.     Next i
  332.     mnuActionsRemove.Enabled = False
  333. End Sub
  334. '------------------------------------------------------------------------------------
  335. ' "Actions -> Add files..." has been choosen in the menu. Open the frmZip dialog
  336. ' that will let the user select what and how to zip.
  337. '------------------------------------------------------------------------------------
  338. Private Sub mnuActionsAdd_Click()
  339.     Dim xErr As xcdError
  340.     Load frmZip
  341.     If frmZip.ShowForm(xZip) Then
  342.         DisableInterface
  343.         Load frmResults
  344.         lblStatusBar.Caption = "Scanning files to zip..."
  345.         xErr = xZip.Zip
  346.         frmResults.Show vbModal
  347.         Unload frmResults
  348.         EnableInterface
  349.         
  350.         ' Update the zip contents list
  351.         UpdateZipContentsList
  352.     End If
  353.     Unload frmZip
  354. End Sub
  355. '------------------------------------------------------------------------------------
  356. ' "Actions -> Unzip files..." has been choosen in the menu. The frmUnzip
  357. ' and the FrmResults (event log) will we loaded and the unzipping
  358. ' operation will be started if the ShowUnzipOptions function returns TRUE.
  359. '------------------------------------------------------------------------------------
  360. Private Sub mnuActionsExtract_Click()
  361.     Dim xErr As xcdError
  362.         
  363.     Load frmUnzip
  364.     If frmUnzip.ShowForm(xZip, lstMain.ListItems) Then
  365.         DisableInterface
  366.         Load frmResults
  367.         lblStatusBar.Caption = "Reading zip file..."
  368.         xErr = xZip.Unzip
  369.         frmResults.Show vbModal
  370.         Unload frmResults
  371.         EnableInterface
  372.         
  373.         ' No need to update the interface
  374.     End If
  375.     Unload frmUnzip
  376. End Sub
  377. '------------------------------------------------------------------------------------
  378. ' "Actions -> Remove files..." has been choosen in the menu. If the
  379. ' LoadRemoveFiles function returns TRUE, it means that the user
  380. ' confirmed that files should be deleted, and so the FrmResults (event log)
  381. ' is we loaded and the Xceed Zip object's RemoveFiles method will be called.
  382. '------------------------------------------------------------------------------------
  383. Private Sub mnuActionsRemove_Click()
  384.     Dim xErr As xcdError
  385.     If ConfirmRemoveFiles Then
  386.         DisableInterface
  387.         Load frmResults
  388.         xErr = xZip.RemoveFiles
  389.         frmResults.Show vbModal
  390.         Unload frmResults
  391.         EnableInterface
  392.         
  393.         UpdateZipContentsList
  394.     End If
  395. End Sub
  396. '------------------------------------------------------------------------------------
  397. ' "Actions -> Test" has been chosen in the menu. This sub. will call the
  398. ' TestZipFile method. The TestingFile event will alert if errors are found.
  399. '------------------------------------------------------------------------------------
  400. Private Sub mnuActionsTest_Click()
  401.     Dim xErr As xcdError
  402.     DisableInterface
  403.     Load frmResults
  404.     xErr = xZip.TestZipFile
  405.     frmResults.Show vbModal
  406.     Unload frmResults
  407.     EnableInterface
  408. End Sub
  409. '------------------------------------------------------------------------------------
  410. ' "File -> Column settings" has been chosen in the menu. The
  411. ' frmSettingsColumns form will be shown.
  412. '------------------------------------------------------------------------------------
  413. Private Sub mnuFileColConfig_Click()
  414.     Load frmOptionsColumns
  415.     frmOptionsColumns.ShowForm xZip
  416.     Unload frmOptionsColumns
  417. End Sub
  418. '------------------------------------------------------------------------------------
  419. ' End of program
  420. '------------------------------------------------------------------------------------
  421. Private Sub mnuFileExit_Click()
  422.     Unload Me
  423. End Sub
  424. '------------------------------------------------------------------------------------
  425. ' "File -> New zip file" has been chosen in the menu. A dialog box will be
  426. ' opened to allow the user to specify the zip file's name and location. Once
  427. ' that has been done, the sample application's AddFiles function will be called,
  428. ' which will allow the user to specify files to add into the zip file right away.
  429. '------------------------------------------------------------------------------------
  430. Private Sub mnuFileNew_Click()
  431.     Dim sZipFilename As String
  432.        
  433.     sZipFilename = SelectZipFile(NewZip) ' Open a dialog to select the Zip file
  434.     If Len(sZipFilename) > 0 Then
  435.         ' The SelectZipFile dialog already warns the user about the
  436.         ' already existing zip file, so we can delete it if it exists
  437.         If Len(Dir(sZipFilename)) > 0 Then
  438.             Kill sZipFilename
  439.         End If
  440.         
  441.         ' Clear the list and update the view
  442.         UpdateZipContentsList
  443.         
  444.         ' Update current zip file
  445.         xZip.ZipFilename = sZipFilename
  446.         
  447.         ' Fake an adding command
  448.         mnuActionsAdd_Click
  449.    End If
  450. End Sub
  451. '------------------------------------------------------------------------------------
  452. ' "File -> Open zip file" has been chosen in the menu. A dialog box is
  453. ' displayed to allow the user to specify the name and location of the
  454. ' zip file to open. If any errors occur, a message box will be shown.
  455. '------------------------------------------------------------------------------------
  456. Private Sub mnuFileOpen_Click()
  457.     Dim sZipFilename As String
  458.     sZipFilename = SelectZipFile(OpenZip) ' Open a dialog to select the Zip file
  459.     If Len(sZipFilename) > 0 Then
  460.         xZip.ZipFilename = sZipFilename
  461.         
  462.         ' Update the zip contents list
  463.         UpdateZipContentsList
  464.     End If
  465. End Sub
  466. '------------------------------------------------------------------------------------
  467. ' "File -> Options..." has been chosen in the menu. The options window will
  468. ' shown.
  469. '------------------------------------------------------------------------------------
  470. Private Sub mnuFileSettings_Click()
  471.     Load frmOptions
  472.     frmOptions.ShowForm xZip
  473.     Unload frmOptions
  474. End Sub
  475. '------------------------------------------------------------------------------------
  476. ' "Help -> About" has been chosen in the menu. The copyright notice will be
  477. ' displayed.
  478. '------------------------------------------------------------------------------------
  479. Private Sub mnuHelpAbout_Click()
  480.     MsgBox "Zip Manager Sample Application for VB6" & vbCrLf & _
  481.            "For the Xceed Zip Compression Library v4.0" & vbCrLf & _
  482.            "Copyright 1995-1999 Xceed Software, All Rights Reserved", vbInformation
  483. End Sub
  484. '------------------------------------------------------------------------------------
  485. ' FileStatus event. This event is triggered when zipping, unzipping, testing, etc.
  486. ' It allows you to show how much of the current file has actually been processed.
  487. ' It also allows you to (as we show here) to find out when a file is actually
  488. ' being zipped or unzipped. This event is triggered once for every 32K processed.
  489. '------------------------------------------------------------------------------------
  490. Private Sub xZip_FileStatus(ByVal sFilename As String, ByVal lSize As Long, _
  491.                             ByVal lCompressedSize As Long, ByVal lBytesProcessed As Long, _
  492.                             ByVal nBytesPercent As Integer, ByVal nCompressionRatio As Integer, _
  493.                             ByVal bFileCompleted As Boolean)
  494.     Select Case xZip.CurrentOperation
  495.     Case xcoZipping
  496.         lblStatusBar.Caption = "Zipping file " & sFilename & " (" & CStr(nBytesPercent) & "%)"
  497.     Case xcoUnzipping
  498.         lblStatusBar.Caption = "Unzipping file " & sFilename & " (" & CStr(nBytesPercent) & "%)"
  499.     Case xcoTestingZipFile
  500.         lblStatusBar.Caption = "Testing file " & sFilename & " (" & CStr(nBytesPercent) & "%)"
  501.     Case xcoRemoving
  502.         lblStatusBar.Caption = "Removing file " & sFilename
  503.     End Select
  504. End Sub
  505. '------------------------------------------------------------------------------------
  506. ' GlobalStatus event. This event is triggered throughout operations such as
  507. ' zipping, unzipping, deleting files, etc. It provides progress information
  508. ' and statistics for the current operation. Our implementation here uses
  509. ' GlobalStatus to update the Global Progress bar underneat the main listbox.
  510. '------------------------------------------------------------------------------------
  511. Private Sub xZip_GlobalStatus(ByVal lFilesTotal As Long, ByVal lFilesProcessed As Long, _
  512.                               ByVal lFilesSkipped As Long, ByVal nFilesPercent As Integer, _
  513.                               ByVal lBytesTotal As Long, ByVal lBytesProcessed As Long, _
  514.                               ByVal lBytesSkipped As Long, ByVal nBytesPercent As Integer, _
  515.                               ByVal lBytesOutput As Long, ByVal nCompressionRatio As Integer)
  516.     prbGlobalProgress.Value = nBytesPercent
  517. End Sub
  518. '------------------------------------------------------------------------------------
  519. ' The InsertDisk event is triggered when another disk is required when reading
  520. ' or writing spanned zip files.
  521. '------------------------------------------------------------------------------------
  522. Private Sub xZip_InsertDisk(ByVal lDiskNumber As Long, bDiskInserted As Boolean)
  523.     Dim xAnswer As VbMsgBoxResult
  524.     If lDiskNumber = 0 Then
  525.         xAnswer = MsgBox("This zip file is part of a multiple disks zip file. Please insert the last disk of the set.", vbInformation + vbOKCancel)
  526.     Else
  527.         xAnswer = MsgBox("Please insert disk #" & CStr(lDiskNumber), vbInformation + vbOKCancel)
  528.     End If
  529.     bDiskInserted = (xAnswer = vbOK)
  530. End Sub
  531. '------------------------------------------------------------------------------------
  532. ' The ListingFile event is triggered for each file listed as a result of
  533. ' calling the ListZipContents method.
  534. '------------------------------------------------------------------------------------
  535. Private Sub xZip_ListingFile(ByVal sFilename As String, ByVal sComment As String, _
  536.                              ByVal lSize As Long, ByVal lCompressedSize As Long, _
  537.                              ByVal nCompressionRatio As Integer, _
  538.                              ByVal xAttributes As XceedZipLibCtl.xcdFileAttributes, _
  539.                              ByVal lCRC As Long, ByVal dtLastModified As Date, _
  540.                              ByVal dtLastAccessed As Date, ByVal dtCreated As Date, _
  541.                              ByVal xMethod As XceedZipLibCtl.xcdCompressionMethod, _
  542.                              ByVal bEncrypted As Boolean, ByVal lDiskNumber As Long, _
  543.                              ByVal bExcluded As Boolean, _
  544.                              ByVal xReason As XceedZipLibCtl.xcdSkippingReason)
  545.     Dim sPathName  As String
  546.     Dim nBackslash As Integer
  547.     Dim xItem      As ListItem
  548.     nBackslash = InStrRev(sFilename, "\")
  549.     If nBackslash > 0 Then
  550.         sPathName = Left(sFilename, nBackslash - 1)                 ' Everything before the backslash
  551.         sFilename = Right(sFilename, Len(sFilename) - nBackslash)   ' Everything after the backslash
  552.     End If
  553.     If (xAttributes And xfaFolder) > 0 Then
  554.         sFilename = "<dir>"
  555.     End If
  556.     ' Format the information for the item and add it to the main listbox.
  557.     Set xItem = lstMain.ListItems.Add(, , sFilename)
  558.       
  559.     ' Put the file attributes information in the correct list column
  560.     xItem.SubItems(1) = sComment
  561.     xItem.SubItems(2) = lSize
  562.     xItem.SubItems(3) = lCompressedSize
  563.     xItem.SubItems(4) = Attributes(xAttributes)
  564.     xItem.SubItems(5) = Hex(lCRC)
  565.     xItem.SubItems(6) = dtLastModified
  566.     xItem.SubItems(7) = dtLastAccessed
  567.     xItem.SubItems(8) = dtCreated
  568.     xItem.SubItems(9) = sPathName
  569.     xItem.SubItems(10) = xMethod
  570.     xItem.SubItems(11) = bEncrypted
  571. End Sub
  572. '------------------------------------------------------------------------------------
  573. ' The ProcessCompleted event is triggered at the end of every operation. It gives
  574. ' you information about the operation, including the number of files processed,
  575. ' the number of files skipped, the compression ratio, and more. If an error has
  576. ' been detected in any operation, that operation will be canceled and the
  577. ' ProcessCompleted event will be triggered immediately.
  578. '------------------------------------------------------------------------------------
  579. Private Sub xZip_ProcessCompleted(ByVal lFilesTotal As Long, ByVal lFilesProcessed As Long, _
  580.                                   ByVal lFilesSkipped As Long, ByVal lBytesTotal As Long, _
  581.                                   ByVal lBytesProcessed As Long, ByVal lBytesSkipped As Long, _
  582.                                   ByVal lBytesOutput As Long, ByVal nCompressionRatio As Integer, _
  583.                                   ByVal xResult As XceedZipLibCtl.xcdError)
  584.     Dim sErrorMessage As String
  585.     sErrorMessage = xZip.GetErrorDescription(xvtError, xResult)
  586.     Select Case xZip.CurrentOperation
  587.     Case xcoZipping
  588.         frmResults.AddMessage "Zipping completed: " & sErrorMessage
  589.         lblStatusBar.Caption = "Zipping completed."
  590.     Case xcoUnzipping
  591.         frmResults.AddMessage "Unzipping completed: " & sErrorMessage
  592.         lblStatusBar.Caption = "Unzipping completed."
  593.     Case xcoRemoving
  594.         frmResults.AddMessage "Removing completed: " & sErrorMessage
  595.         lblStatusBar.Caption = "Removing completed."
  596.     Case xcoTestingZipFile
  597.         frmResults.AddMessage "Testing completed: " & sErrorMessage
  598.         lblStatusBar.Caption = "Testing completed."
  599.     End Select
  600. End Sub
  601. '------------------------------------------------------------------------------------
  602. ' The RemovingFile event is triggered when the RemoveFiles method is called. It
  603. ' gives information about each file being deleted: filename, size, etc.
  604. '------------------------------------------------------------------------------------
  605. Private Sub xZip_RemovingFile(ByVal sFilename As String, ByVal sComment As String, _
  606.                               ByVal lSize As Long, ByVal lCompressedSize As Long, _
  607.                               ByVal xAttributes As XceedZipLibCtl.xcdFileAttributes, _
  608.                               ByVal lCRC As Long, ByVal dtLastModified As Date, _
  609.                               ByVal dtLastAccessed As Date, ByVal dtCreated As Date, _
  610.                               ByVal xMethod As XceedZipLibCtl.xcdCompressionMethod, _
  611.                               ByVal bEncrypted As Boolean)
  612.     frmResults.AddMessage "Removing " & sFilename
  613. End Sub
  614. '------------------------------------------------------------------------------------
  615. ' The SkippingFile event is triggered when a file is skipped from an adding or
  616. ' extracting operation. It does not necessarily mean that the current operation
  617. ' has caused an error. A file may be skipped due to the RequiredFile attributes,
  618. ' ExcludedFileAttributes, Min and MaxSize and Min and MaxDate.
  619. '------------------------------------------------------------------------------------
  620. Private Sub xZip_SkippingFile(ByVal sFilename As String, ByVal sComment As String, _
  621.                               ByVal sFilenameOnDisk As String, ByVal lSize As Long, _
  622.                               ByVal lCompressedSize As Long, _
  623.                               ByVal xAttributes As XceedZipLibCtl.xcdFileAttributes, _
  624.                               ByVal lCRC As Long, ByVal dtLastModified As Date, _
  625.                               ByVal dtLastAccessed As Date, ByVal dtCreated As Date, _
  626.                               ByVal xMethod As XceedZipLibCtl.xcdCompressionMethod, _
  627.                               ByVal bEncrypted As Boolean, _
  628.                               ByVal xReason As XceedZipLibCtl.xcdSkippingReason)
  629.     frmResults.AddMessage "Skipping " & sFilename & ": " & xZip.GetErrorDescription(xvtSkippingReason, xReason)
  630. End Sub
  631. '------------------------------------------------------------------------------------
  632. ' The TestingFile event is triggered when a file is read from the zip file for
  633. ' testing. All files are listed this way. Then the unzipping test starts, and
  634. ' FileStatus and GlobalStatus are triggered.
  635. '------------------------------------------------------------------------------------
  636. Private Sub xZip_TestingFile(ByVal sFilename As String, ByVal sComment As String, _
  637.                              ByVal lSize As Long, ByVal lCompressedSize As Long, _
  638.                              ByVal nCompressionRatio As Integer, _
  639.                              ByVal xAttributes As XceedZipLibCtl.xcdFileAttributes, _
  640.                              ByVal lCRC As Long, ByVal dtLastModified As Date, _
  641.                              ByVal dtLastAccessed As Date, ByVal dtCreated As Date, _
  642.                              ByVal xMethod As XceedZipLibCtl.xcdCompressionMethod, _
  643.                              ByVal bEncrypted As Boolean, ByVal lDiskNumber As Long)
  644.     frmResults.AddMessage "Testing " & sFilename
  645. End Sub
  646. '------------------------------------------------------------------------------------
  647. ' The UnzipPreprocessingFile event is triggered before a file gets to the physical
  648. ' unzipping operation. It does not mean that the unzipping operation is successful.
  649. '------------------------------------------------------------------------------------
  650. Private Sub xZip_UnzipPreprocessingFile(ByVal sFilename As String, ByVal sComment As String, _
  651.                                         sDestFilename As String, ByVal lSize As Long, _
  652.                                         ByVal lCompressedSize As Long, _
  653.                                         xAttributes As XceedZipLibCtl.xcdFileAttributes, _
  654.                                         ByVal lCRC As Long, dtLastModified As Date, _
  655.                                         dtLastAccessed As Date, dtCreated As Date, _
  656.                                         ByVal xMethod As XceedZipLibCtl.xcdCompressionMethod, _
  657.                                         ByVal bEncrypted As Boolean, sPassword As String, _
  658.                                         ByVal lDiskNumber As Long, bExcluded As Boolean, _
  659.                                         ByVal xReason As XceedZipLibCtl.xcdSkippingReason, _
  660.                                         ByVal bExisting As Boolean, _
  661.                                         xDestination As XceedZipLibCtl.xcdUnzipDestination)
  662.     If (Not bExcluded) Then
  663.         'Adds a description line to the Results form window
  664.         frmResults.AddMessage "Unzipping " & sFilename
  665.     End If
  666. End Sub
  667. '------------------------------------------------------------------------------------
  668. ' The Warning event occurs during any operation that encounters a recoverable error.
  669. '------------------------------------------------------------------------------------
  670. Private Sub xZip_Warning(ByVal sFilename As String, ByVal xWarning As XceedZipLibCtl.xcdWarning)
  671.     frmResults.AddMessage "Warning: " & xZip.GetErrorDescription(xvtWarning, xWarning)
  672. End Sub
  673. '------------------------------------------------------------------------------------
  674. ' The ZipContentsStatus event occurs whenever a zip file needs to be read. We only
  675. ' update the progress bar while listing.
  676. '------------------------------------------------------------------------------------
  677. Private Sub xZip_ZipContentsStatus(ByVal lFilesRead As Long, ByVal lFilesTotal As Long, ByVal nFilesPercent As Integer)
  678.     If xZip.CurrentOperation = xcoListing Then
  679.         prbGlobalProgress.Value = nFilesPercent
  680.     End If
  681. End Sub
  682. '------------------------------------------------------------------------------------
  683. ' The ZipPreprocessingFile event is triggered right before a file is actually
  684. ' zipped. You can decide, in this event, whether or not you really want the file
  685. ' to be zipped (use the bExcluded parameter) or you can change some of the file's
  686. ' information before it is zipped. This event doesn't mean the file has been
  687. ' actually zipped yet.
  688. '------------------------------------------------------------------------------------
  689. Private Sub xZip_ZipPreprocessingFile(sFilename As String, sComment As String, _
  690.                                       ByVal sSourceFilename As String, ByVal lSize As Long, _
  691.                                       xAttributes As XceedZipLibCtl.xcdFileAttributes, _
  692.                                       dtLastModified As Date, dtLastAccessed As Date, _
  693.                                       dtCreated As Date, _
  694.                                       xMethod As XceedZipLibCtl.xcdCompressionMethod, _
  695.                                       bEncrypted As Boolean, sPassword As String, _
  696.                                       bExcluded As Boolean, _
  697.                                       ByVal xReason As XceedZipLibCtl.xcdSkippingReason, _
  698.                                       ByVal bExisting As Boolean)
  699.     'Adds a description line to the Results form window if the
  700.     'file is not excluded from the zipping operation
  701.     If (Not bExcluded) Then
  702.         frmResults.AddMessage "Zipping " & sFilename
  703.     End If
  704. End Sub
  705. '------------------------------------------------------------------------------------
  706. ' Disable all options while processing. Enable the abort button and show the
  707. ' progress bar.
  708. '------------------------------------------------------------------------------------
  709. Public Sub DisableInterface()
  710.     ' Disable menu items
  711.     frmMain.mnuFile.Enabled = False
  712.     frmMain.mnuActions.Enabled = False
  713.     frmMain.mnuHelp.Enabled = False
  714.     ' Activate the Abort button and show the progress bar
  715.     cmdAbort.Enabled = True
  716.     prbGlobalProgress.Visible = True
  717.     lblProgress.Visible = True
  718. End Sub
  719. '------------------------------------------------------------------------------------
  720. ' Enable options depending on current state (zip file opened or not), disable abort
  721. ' button and hide progress bar.
  722. '------------------------------------------------------------------------------------
  723. Public Sub EnableInterface()
  724.     frmMain.mnuActions.Enabled = (Len(xZip.ZipFilename) > 0)
  725.     frmMain.mnuFile.Enabled = True
  726.     frmMain.mnuHelp.Enabled = True
  727.     'Deactivate the Abort button and hide the progress bar
  728.     cmdAbort.Enabled = False
  729.     prbGlobalProgress.Visible = False
  730.     lblProgress.Visible = False
  731. End Sub
  732. '------------------------------------------------------------------------------------
  733. ' Ask the user to confirm the removal of the selected files.
  734. '------------------------------------------------------------------------------------
  735. Private Function ConfirmRemoveFiles() As Boolean
  736.     Dim xAnswer As VbMsgBoxResult
  737.     xAnswer = MsgBox("The selected file(s) will be removed from the zip file. Continue?", vbOKCancel)
  738.     If xAnswer = vbOK Then
  739.         xZip.ProcessSubfolders = False
  740.         xZip.FilesToProcess = GetSelectedFiles(lstMain.ListItems, True)
  741.     End If
  742.     ConfirmRemoveFiles = (xAnswer = vbOK)
  743. End Function
  744.